ABC169 D - Div Game
提出
code: python
import itertools
n = int(input())
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp % i == 0:
cnt = 0
while temp %i ==0:
cnt += 1
temp //= i
if temp != 1:
if arr == []:
return arr
# print(factorization(n))
nums = set()
for i in factorization(n):
for i in itertools.permutations(nums, len(nums)):
# (36954241, 5, 4, 2, 9, 3, 8, 25, 125, 6079, 27) 多すぎる
解答
code: python
from collections import Counter
n = int(input())
def prime_factorization(n):
table = []
for x in range(2, int(n ** 0.5) + 1):
while n % x == 0:
table.append(x)
n //= x
if n > 1:
table.append(n)
return table
# print(prime_factorization(n))
c = Counter(prime_factorization(n))
# print(Counter(prime_factorization(n)))
# Counter({2: 3, 3: 1})
ans = 0
for i in c.values():
# 1個使う
nx = 1
while (i >= nx):
i -= nx
ans += 1
# 2個使う...
nx += 1
print(ans)
テーマ
提出
code: python
n = int(input())
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
if temp!=1:
if arr==[]:
return arr
factor = factorization(n)
# print(factor)
# z全部挙げられる?
# どれをpikupするか
# ~/Desktop/python_playground
# $ python3 -u "/Users/wafuwafu13/Desktop/python_playground/index.py"
# 810
# ~/Desktop/python_playground
# $ python3 -u "/Users/wafuwafu13/Desktop/python_playground/index.py"
# 405
# 3, 4], [5, 1
# 何個取るか 別個に取ることは考えないでいい? <- メリットがない
# 1 -> 1 2 -> 3 3 -> 6 4 -> 10
# 高々15
ans = 0
for f in factor:
continue
for i in range(1, 16):
ans += 1
else:
break
print(ans)